#!/usr/bin/perl
#index.cgi
require './servermin-lib.pl';

&header($text{'index_title'}, "", "index", 0, 1);
#print "<hr>\n";
print "<form action=save_server.cgi method=post onsubmit='document.forms[0].saveok.disabled = true;'>\n";
print "<table class=mode1>\n";
print "<tr> <td><b>$text{'host_name'}</b></td>\n";
my $hn = &get_system_hostname();
print "<td><input name=hostnamein value=$hn class=text></td> </tr>\n";

#print "<tr> <td colspan=2><hr></td> </tr>\n";

print "<tr> <td valign=top><b>$text{'member_of'}</b></td>\n";
print "<td><table class=mode1>\n";
&foreign_require("samba", "samba-lib.pl");
$wg = &foreign_call("samba", "getval", "workgroup");
$security = &foreign_call("samba", "getval", "security");
`echo $security > /root/valuu`;
printf "<tr> <td><input type=hidden name=oldsecurity value=$security><input type=radio name=memberrdn %s value='0'>$text{'workgroup'}</td>\n", ($security =~ /^user/)?"checked":"";
printf "<td><input name=workgroupin value='%s' class=text></td> </tr>\n", ($security =~ /^user/)?$wg:"";
printf "<tr> <td><input type=radio name=memberrdn %s value='1'>$text{'domain'}</td>\n", ($security =~ /^ADS/)?"checked":"";
printf "<td><input name=domainin value='%s' class=text></td></tr></table>\n", ($security =~ /^ADS/)?$wg:"";
print "<tr> <td colspan=2><table class=mode1><tr><td><b>$text{'pdc'}</b></td>\n";
$pdc = &foreign_call("samba", "getval", "realm");
print "<td><input name=pdcin value='$pdc' class=text></td> </tr> \n";
print "<tr> <td colspan=2><table class=mode1><tr><td><b>$text{'admin_ip'}</b></td>\n";
print "<td><input name=ipin value='' class=text></td> </tr> \n";
#print "<tr> <td></td><td><i>$text{'join_hint'}</i></td> </tr>\n";
print " <td><b>$text{'admin_user'}</b></td>\n";
print "<td><input name=userin class=text></td> </tr>\n";
print "<tr> <td><b>$text{'admin_pass'}</b></td>\n";
print "<td><input type=password name=passin class=text></td> </tr>\n";


print "</table></td> </tr>\n";
print "</table>\n";
print "<input type=submit name=saveok value=$text{'submit'} class=button1>\n";
print "</form>\n";
#print "<i>$text{'domain_hint'}</i>\n";
#print "<hr>\n";
&nas_syslog("servermin", "naslog_info", 33000, "Get server appliance identity");
&footer("/", $text{'index'});
